<template>
<div class="idshowapi-wrapper" v-if="col.rs">
  <template v-for="(info,ind) in infos">

      <span v-show="false">
          {{b=col.auths?col.auths.contains(info.menu_id):false}}
          {{check=col.is_admin||b}}
      </span>

  <span v-if="useLink&&check">
      <router-link v-if="info.id" :to="{path:'/page/list',query:{ctl:info.ctl,id:info.id}}">
        <span v-show="false">{{_name=info.name==0?null:info.name}}</span>
        {{_name||(info.id>0?`ID:${info.id}`:'')}}</router-link>
    </span>
    <span v-else>
      <span v-show="false">{{_name=info.name==0?null:info.name}}</span>
        {{_name||(info.id>0?`ID:${info.id}`:'')}}
    </span>
    <template v-if="ind<infos.length-1">&nbsp;|&nbsp;</template>
  </template>
</div>
</template>
<script type="text/ecmascript-6">
import tool from 'src/util/tool';
import util from '_util/index';
import in_array from 'in_array';


export default {
  data() {
    return {
      infos: [],
      name: null,
      id: null,
      ctl: null,
    }
  },
  watch: {
    col: function() {
      this.setInfo();
    }
  },
  methods: {

    setInfo() {
      this.infos = [];
      if(this.col.rs&&util.isString(this.col.rs)){

        let [id,name,ctl,menu_id] = this.col.rs.split('#:#');

//          tool.cl([id, name, ctl, menu_id]);

        if(id.indexOf('|')){
          let ids = id.split('|');
          let names = name.split('#|#');
          ids.forEach((id, ind)=> {
            this.infos.push({id, name:names[ind], ctl,menu_id});
          });
        }else
          this.infos.push({id, name, ctl,menu_id});

      }

    }
  },
  props: ['col'],
  computed: {
      useLink(){
//          let not_use = ['Refundorders','Trodetail','Trosp','Product','TopProduct'];
          let not_use = ['Refundorders','Trodetail','Trosp'];
          let ctl = this.$route.query.ctl;
          return !in_array(ctl,not_use);
      }
  },
  created() {
    this.setInfo();
  }
};
</script>
<style rel="stylesheet/less" lang="less">@dir: "cell/";</style>
